<script type="text/javascript">
    $.validator.setDefaults({
        submitHandler: function() {
            $.post("<?= site_url() ?>setup/add_facility", {
                name: $('#name').val(),
                type: $('#type').val(),
				desc: $('#desc').val()
            },
            function(data) {
                window.location = '<?php echo base_url();?>setup/work_facility';
            });
        }
    });

    $(document).ready(function() {
        $("#formuser").keypress(function(e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $.validator.setDefaults({
                    submitHandler: function() {
                        $.post("<?= site_url() ?>setup/add_facility", {
                            name: $('#name').val(),
							type: $('#type').val(),
							desc: $('#desc').val()
                        },
                        function(data) {
                            window.location = '<?php echo base_url();?>setup/work_facility';
                        });
                    }
                });
            }
        });

        $("#formuser").validate();
    });

    function cancel() {
        window.location = '<?php echo base_url();?>setup/work_facility';        
    }
</script>

<form method="post" id="formuser" action="#" enctype="multipart/form-data" class="form-horizontal" role="form">
    <div class="col-md-offset-1">
		<div class="col-md-11">
			<div class="panel-body well">
				<h4><b class="caret"></b><b> Form - Add Facility</b></h4>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_room" class="control-label">Facility Name<span style="color:red;">*</span></label></div>
					<div class="col-sm-5"><input type="text" class="form-control input-sm required" id="name" name="name" maxlength="30"></div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_room" class="control-label">Facility Description</label></div>
					<div class="col-sm-4"><input type="text" class="form-control input-sm" id="desc" name="desc" maxlength="30"></div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="l_type" class="control-label">Facility Type<span style="color:red;">*</span></label></div>
					<div class="col-sm-4">
						<select name="type" id="type" class="form-control input-sm required">					
							<option value="FASKER" <?php echo $type=='FASKER'?'selected':''; ?>>Fasilitas Kerja</option>
							<option value="RUAKER" <?php echo $type=='RUAKER'?'selected':''; ?>>Fasilitas Ruang Kerja</option>					
						</select>
					</div>										
				</div>			
				<div class="col-sm-8" style="padding-bottom: 20px;">
					<div class="col-sm-4">
						&nbsp;
					</div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="button" class="control-label">&nbsp;</label></div>
					<div class="col-sm-4">
						<button type="submit" class="btn btn-success btn-block"><!--span class="glyphicon glyphicon-saved"></span--> Save Add</button>
					</div>
					<div class="col-sm-4">
						<button type="button" class="btn btn-default btn-block" onclick="cancel();"><!--span class="glyphicon glyphicon-circle-arrow-left"></span--> Cancel</button>
					</div>
				</div>
			</div>
        </div>
	</div>
</form>
